﻿@using DualControl.CommonServices
@using DualControl.ControlMeasures.Dtos

@model Abp.Application.Services.Dto.ListResultDto<HSControlMeasureListDto>
@using X.PagedList.Mvc.Core; @*import this so we get our HTML Helper*@
@using X.PagedList; @*import this so we can cast our list to IPagedList (only necessary because ViewBag is dynamic)*@

@inject ICommonService CommonService

@{
    ViewData["Title"] = "主要管控措施";
}

@section scripts
    {
    <environment names="Development">
        <script src="~/view-resources/Views/ControlMeasures/Index.js" asp-append-version="true"></script>
    </environment>
    <environment names="Staging,Production">
        <script src="~/view-resources/Views/ControlMeasures/Index.min.js" asp-append-version="true"></script>
    </environment>
}
<style>
    .table tbody tr th td {
        vertical-align: middle;
    }
</style>

<div class="row clearfix">
    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
        <div class="card">
            <div class="header">
                <h2>
                    @L("ControlMeasure")
                </h2>
                <ul class="header-dropdown m-r--5">
                    <li class="dropdown">
                        <a href="javascript:void(0);" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
                            <i class="material-icons">more_vert</i>
                        </a>
                        <ul class="dropdown-menu pull-right">
                            <li><a id="RefreshButton" href="javascript:void(0);" class="waves-effect waves-block"><i class="material-icons">refresh</i>@L("Refresh")</a></li>
                        </ul>
                    </li>
                </ul>
            </div>
            <div class="body table-responsive">
               


                @foreach (var hazardsource in ViewBag.PageOfHSControlMeasureListDto)
                {
                   
                <div class="panel panel-primary">
                    <div class="panel-heading">
                        <h3 class="panel-title">
                            风险点编码：@hazardsource.Code &nbsp; 风险点名称：@hazardsource.RiskPointName &nbsp; 车间/班组：@CommonService.GetOrganizationUnits().SingleOrDefault(c => c.Key == @hazardsource.OrganizationUnitId).Value   
                        </h3>
                    </div>
                    <div class="panel-body">
                        <h4 class="panel-title">危险源名称：@hazardsource.HazardSourceName  &nbsp;风险因素：@hazardsource.RiskFactor</h4>
                       
                    </div> 
                    <table class="table">
                        <thead>
                            <tr>
                                <th width="10%">序号</th>
                                <th width="50%">管控措施</th>                               
                               
                                <th width="30%">操作</th>
                            </tr>
                        </thead>

                        @{ if (hazardsource.ControlMeasures.Count > 0)
                            {


                                int i = 0;

                                @foreach (var controlmeasure in hazardsource.ControlMeasures)
                                {

                                    i++;
                                    <tr>
                                        <td>@i.</td>
                                        <td>
                                            @controlmeasure.ControlContent
                                        </td>
                                        <td>
                                            <span class="glyphicon glyphicon-pencil"></span>
                                            <button class="edit-controlmeasure" data-controlmeasure-id="@controlmeasure.Id" data-controlmeasure-controlcontent="@controlmeasure.ControlContent" data-toggle="modal" data-target="#ControlMeasureEditModal">编辑</button>
                                        
                                            <span class="glyphicon glyphicon-remove"></span> <button class="delete-controlmeasure" data-controlmeasure-id="@controlmeasure.Id" data-hazardsource-name="">删除</button>
                                        </td>

                                       
                                    </tr>

                                }
                            }

                        }
                        <tr><td>
    <button type="button" class="btn btn-primary btn-circle waves-effect waves-circle waves-float pull-left" data-toggle="modal" data-hazardsource-id="@hazardsource.Id" data-riskpoint-id="@hazardsource.RiskPointId" data-organizationunit-id="@hazardsource.OrganizationUnitId" data-target="#ControlMeasureCreateModal">
        <i class="material-icons">add</i>
    </button>
</td></tr>

                    </table>
                       
                    </div>
                }
            </div>
        </div>
    </div>
</div>

@Html.PagedListPager((IPagedList)ViewBag.PageOfHSControlMeasureListDto, page => Url.Action("Index", new { page }))

<div class="modal fade" id="ControlMeasureCreateModal" tabindex="-1" role="dialog" aria-labelledby="HazardSourceCreateModalLabel" data-backdrop="static">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title">
                    <span>主要管控措施</span>
                </h4>
            </div>
            <div class="modal-body">
                <form name="controlMeasureCreateForm" role="form" novalidate class="form-validation">
                    <input type="hidden" name="HazardSourceId" id="HazardSourceId" />
                    <input type="hidden" name="RiskPointId" id="RiskPointId" />
                    <input type="hidden" name="OrganizationUnitId" id="OrganizationUnitId" />
                   
                    <div class="tab-content">
                        <div role="tabpanel" class="tab-pane animated fadeIn active" id="create-org-details">
                            <div class="row clearfix" style="margin-top:10px;">
                                <div class="col-sm-6">
                                    <div class="form-group form-float">
                                        <label class="form-label">管控措施1</label>
                                        <textarea class="form-control" id="controlmeasure1" type="text"   name="controlmeasure1" required minlength="3" placeholder="请输入管控措施" autofocus></textarea>
                                       
                                    </div>
                                </div>
                                <div class="col-sm-6">
                                    <div class="form-group form-float">
                                        <label class="form-label">管控措施2</label>
                                        <textarea class="form-control" type="text" name="controlmeasure2" id="controlmeasure2" placeholder="请输入管控措施"></textarea>

                                    </div>
                                </div>

                            </div>

                            <div class="row clearfix" style="margin-top:10px;">
                                <div class="col-sm-6">
                                    <div class="form-group form-float">
                                        <label class="form-label">管控措施3</label>
                                        <textarea class="form-control" type="text" id="controlmeasure3" name="controlmeasure3" placeholder="请输入管控措施"></textarea>


                                    </div>
                                </div>

                                <div class="col-sm-6">
                                    <div class="form-group form-float">
                                        <label class="form-label">管控措施4</label>
                                        <textarea class="form-control" type="text" id="controlmeasure4" name="controlmeasure4" placeholder="请输入管控措施"></textarea>                                    

                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default waves-effect" data-dismiss="modal">@L("Cancel")</button>
                        <button type="submit" class="btn btn-primary waves-effect">@L("Save")</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="ControlMeasureEditModal" tabindex="-1" role="dialog" aria-labelledby="HazardSourceEditModalLabel" data-backdrop="static">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title">
                    <span>编辑管控措施</span>
                </h4>
            </div>
            <div class="modal-body">
                <form name="hazardSourceEditForm" role="form" novalidate class="form-validation">
                    <input type="hidden" name="Id" id="Id" />               <div class="tab-content">
                        <div role="tabpanel" class="tab-pane animated fadeIn active" id="create-org-details">
                            <div class="row clearfix" style="margin-top:10px;">
                                <div class="col-sm-6">
                                    <div class="form-group form-float">
                                        <label class="form-label">管控措施</label>
                                        <input class="form-control" type="text" id="ControlContent" name="ControlContent" required minlength="3" placeholder="输入管控措施">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default waves-effect" data-dismiss="modal">@L("Cancel")</button>
                        <button type="submit" class="btn btn-primary waves-effect">@L("Save")</button>
                    </div>
                </form>
            </div>
        </div>
    </div>

</div>
